﻿@using EquipmentManager.Entities
@model EquipmentManager.Models.ListModel<Region, Directorate>

@{
    ViewBag.Title = "Список районов";
}

@section menu {
    <section class="featured">
            <div class="master-menu">
                @{Html.RenderPartial("AdminMenu");}
            </div>
    </section>
}

<p>@Html.ActionLink("+ Добавить новый район", "CreateRegion", "Admin", new { @DirectorateId = Model.Parent.Id}, new { @class = "common-btn BlueColor" })</p>

<h2>Список районов @Model.Parent.Name</h2>

<table class="bordered">
    <thead>
        <tr>
            <th>Отделения</th>
            <th>Добавить</th>
            <th>Добавить</th>
            <th>Название</th>
            <th>Пользователей</th>
            <th>Отделений</th>
            <th>Правка</th>
            <th>Удалить</th>
        </tr>
    </thead>
    @foreach (var region in Model.ListItems)
    {
        <tr>
            <td class="Center column-detail">@Html.ActionLink("Отделения", "PostOffices", "Admin", new { RegionId = region.Id }, new { @class = "common-btn BlueColor" })</td>
            <td class="Center column-detail">@Html.ActionLink("+ Отделение", "CreatePostOffice", "Admin", new { RegionId = region.Id }, new { @class = "common-btn BlueColor" })</td>
            <td class="Center column-detail">@Html.ActionLink("+ Юзер", "CreateUser", "Admin", new { RegionId = region.Id }, new { @class = "common-btn BlueColor" })</td>
            <td>@region.Name</td>
            <td class="Center">@region.Users.Where(u => u.Status == EntityStatus.Active).Count()</td>
            <td class="Center">@region.PostOffices.Where(p => p.Status == EntityStatus.Active).Count()</td>
            <td class="Center column-detail">@Html.ActionLink("Правка", "EditRegion", "Admin", new { RegionId = region.Id }, new { @class = "common-btn BlueColor" })</td>
            <td class="Center column-detail">@Html.ActionLink("Удалить", "DeleteRegion", "Admin", new { RegionId = region.Id }, new { @class = "common-btn RedColor" })</td>
        </tr>
    }
</table>

<p>
     @Html.ActionLink("Назад", "Directorates", "Admin", new { @class = "common-btn-large BlueColor" })
</p>